<template>
<div class=''>
    <el-dialog title="订单结算" :visible.sync="dialogTableVisible">
				<el-form :model="zf">
                    <el-form-item label="余额充值">
                        <el-radio v-model="zf.fs" label="1">现金支付</el-radio>
                         
					</el-form-item>
                    <el-row :gutter="10">
                     <el-col :span="8">
                 <el-form-item label="充值客户" >
                    <el-input v-model="zf.kh" :readonly="rdy"></el-input>
                </el-form-item>
                     </el-col>
                     <el-col :span="8">
                 <el-form-item label="充值金额">
                    <el-input v-model="zf.je"></el-input>
                </el-form-item>
                     </el-col>
                    </el-row>
				</el-form>
				<div slot="footer" class="dialog-footer">
					<el-button @click="dialogTableVisible = false">取 消</el-button>
					<el-button type="primary" @click="qdzf()">确 定</el-button>
				</div>
			</el-dialog>
    <el-form ref="form" :model="form" label-width="80px">
    <el-row :gutter="10">
    <el-col :span="6">
    <el-select v-model="form.xz" placeholder="请选择活动区域" @change="xzgb()">
      <el-option label="普通客户" value="0"></el-option>
      <el-option label="会员客户" value="1"></el-option>
    </el-select>
    </el-col>
    <el-col :span="6">
    <el-input v-model="form.name" placeholder="请选输入客户电话号码" @change="xzgb()"></el-input>
    </el-col>
  </el-row>
    </el-form>
<template>
  <el-table
    :data="list"
    border
    style="width:1300px">
    <el-table-column
      prop="username"
      label="客户名称"
      width="180">
    </el-table-column>
    <el-table-column
      prop="userphone"
      label="手机号码"
      width="180">
    </el-table-column>
    <el-table-column
      prop="uamount"
      label="余额" width="180">
    </el-table-column>
    <el-table-column
      prop="uintegral"
      label="积分" width="180">
    </el-table-column>
    <el-table-column label="操作" width="300">
						<template slot-scope="scope">
							<el-button type="success" icon="el-icon-success"  @click="cz(scope.row)">充值</el-button>
							<el-button type="primary" icon="el-icon-key"  @click="sjhy(scope.row)">解锁会员</el-button>
						</template>

					</el-table-column>
  </el-table>
</template>

</div>
</template>

<script>
export default {
data() {
//这里存放数据
return {
    form:{
         xz:"0",
         name:"",
         number:""
    },
    list:[],
    dialogTableVisible: false,
    zf:{
        fs:"1",
        kh:"",
        je:"",
    },
    rdy:true,
    khcz:{},
    number:"",
};
},
//计算属性
computed: {},
//方法集合
methods: {
    cx(){
        let thiss=this
        this.$http.get("http://localhost:8080/c/user/qvip", {
		params: {
							vipid:this.form.xz,
                            zhi:this.form.name
						}
					}).then(resp => {
						//console.info(resp.data)
						thiss.list = resp.data
					})
    },
    xzgb(){
        this.cx();
    },
    cz(obj){
        console.info(obj)
        this.dialogTableVisible = true
        this.zf.kh=obj.username
		this.khcz=obj
    },
    sjhy(obj){
        //console.info(obj)
        let th=this
        if(obj.isvip==1){
            this.$message({
								showClose: true,
								message: '已成为会员',
								type: 'success'
							});
        }else{
            if(obj.uintegral<100){
                this.$message.error('积分不足100，无法兑换');
            }else{
                obj.uintegral-=100;
                obj.isvip=1
                this.$http.put("http://localhost:8080/c/user/mvip",obj).then(resp=>{
                    if(resp.data>0){
                         this.$message({
								showClose: true,
								message: '恭喜成为成为会员',
								type: 'success'
							});
                        th.cx();
                    }
                })
            }
        }
    },
    qdzf(){
        let thiss=this
        if(this.zf.fs==1){
            this.khcz.uamount=this.zf.je*1+this.khcz.uamount*1
            //alert( this.khcz.uamount)

             this.$http.put("http://localhost:8080/c/user/mye",this.khcz).then(resp=>{
                 if(resp.data>0){
                         this.$message({
								showClose: true,
								message: '充值成功',
								type: 'success'
							});
                            thiss.cx();
                            thiss.zf.je=""
                            thiss.dialogTableVisible = false;
                    }
             })
        }else{
            this.khcz.uamount=this.zf.je*1+this.khcz.uamount*1
            this.$http.put("http://localhost:8080/c/user/mye",this.khcz).then(resp=>{
                 if(resp.data>0){
                         this.$message({
								showClose: true,
								message: '充值成功',
								type: 'success'
							});
                            thiss.cx();
                            thiss.zf.je=""
                            thiss.dialogTableVisible = false;
                    }
                    
             })
           
        }
    
    },


    


},
//挂载完成（可以访问DOM元素）
mounted() {
    this.cx();
   // this.created();
},
//监控data中的数据变化
watch: {

}
}
</script>
<style  scoped>
/*@import url(); 引入公共css类*/

</style>